<?php
// Copyright 2012 @Wondershare
// $Id: MetaInfo.php 437020 2012-07-11 08:46:41Z xuwh $

class MetaInfo extends CConfiguration
{
    private $_seoitems;
    public function __construct ()
    {
        $this->_seoitems = array_keys(Yii::app()->params['seoitems']);
        if (! $this->hasProperty('seotitle')) {
            $this->setMeta();
        }
    }
    private function setMeta ()
    {
        $metalist = Option::model()->cache(1)->findByPk(1);
        if (empty($metalist))
            $metalist = Yii::app()->params['seoitems'];
        foreach ($this->_seoitems as $seoitem) {
            $this->add($seoitem, $metalist->$seoitem);
        }
    }
    public function getMeta ()
    {
        $keys = $this->getKeys();
        if (empty($keys)) {
            return false;
        } else {
            $metainfo = array();
            foreach ($keys as $key) {
                $metainfo[$key] = $this->itemAt($key);
            }
//            Cache::begin();
//            Cache::setvalue();
//            Cache::getvalue();
        }
        return $metainfo;
    }
}